package com.dylan.distruptor;

public class TestRingQueue {

    public static void main(String[] args) {
        final RingQueue queue = new RingQueue(16);
        Thread producer = new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 0;
                while (true) {
                    queue.put(i++);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        producer.start();


        Thread consumer = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    Object take = queue.take();
                    System.out.println(take);
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        consumer.start();
    }
}
